﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using App.Utilities.Web.Handlers;
using CRMBiz;
using Newtonsoft.Json;
using System.Data;
namespace CRMWeb.WebServices
{
    public class DualTemplate : BaseHandler
    {
        public override void OnMethodInvoke(OnMethodInvokeArgs e)
        {
            context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
            context.Response.Cache.SetExpires(DateTime.MinValue);
            context.Response.Cache.SetNoStore();
            SetResponseContentType(ResponseContentTypes.HTML);
        }

        public override void AfterMethodInvoke(object result)
        {
            base.AfterMethodInvoke(result);
        }

        public void GetAllDualTemplate()
        {
            try
            {
                string strJson = JsonConvert.SerializeObject(DualTemplateHandler.GetCategoryNodesList());
                context.Response.Write(strJson);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void GetDualTemplateContentById(int DualTemplateId)
        {
            try
            {
                string strJson = JsonConvert.SerializeObject(DualTemplateHandler.GetDualTemplates(DualTemplateId));
                context.Response.Write(strJson);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void DisplayDualTemplateNode()
        {
            try
            {
                string strJson = JsonConvert.SerializeObject(DualTemplateHandler.GetCategoryNodesList());
                context.Response.Write(strJson);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void DisplayDualCategoryList()
        {
            try
            {
                bool isSMS = true;
                string strJson = JsonConvert.SerializeObject(CategoryNodeHandler.GetCategoryNodesList(isSMS, true, true));
                context.Response.Write(strJson);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void GetAllDualTemplate1()
        {
            try
            {
                string strJson = JsonConvert.SerializeObject(DualTemplateHandler.GetDualTemplates1());
                context.Response.Write(strJson);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void saveDualTemplate(string DualTemplateID, string DualSubject, string DualTemplate, string SmsTemplateID, string EmailTemplateID, int CategoryID)
        {
            try
            {
                DualTemplateHandler.saveDualTemplate(Convert.ToInt32(DualTemplateID), DualSubject, DualTemplate, Convert.ToInt32(SmsTemplateID), Convert.ToInt32(EmailTemplateID), CategoryID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void deleteDualTemplate(int DualTemplateID)
        {
            try
            {
                DualTemplateHandler.deleteDualTemplate(DualTemplateID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}